﻿// Defining the callback function raised when the main page will call us
self.addEventListener('message', function (e) {
	if (typeof e.data.n != "number") {
		throw new TypeError("p7dc.web.html5.worker.js: e.data.n == null");
	}
	// Preparing the message that we will send back
	var calc = 0;
	for (var i = 0; i < e.data.n; i++) {
		calc += 1;
	}
	// Posting back the message to the main page
	self.postMessage(calc);
}, false);

//window.onload = function () {
//	// Worker
//	if (!!window.Worker) {
//		var worker = new Worker("@Links.Scripts.p7dc_web_worker_js");
//		worker.onmessage = function (event) {
//			worker.terminate(); // Stop worker
//			alert(event.data);
//		};
//		worker.onerror = function (event) {
//			alert(event);
//		};
//		worker.postMessage({ n: 10000 }); // Start worker
//	}
//}